﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MangoMes.Write.API.Applications.Login;
using MediatR;

namespace ManagoMes.Read.API.Applications.WangDefa
{
    public class processBackHandler : IRequestHandler<processBackcommond, ResultsDTO<processk>>
    {

        private readonly IBateRepository<processk> _processk;
        private readonly Logincommonality _Logincommonality;

        public processBackHandler(IBateRepository<processk> processk, Logincommonality logincommonality)
        {
            _processk = processk;
            _Logincommonality = logincommonality;
        }

        public async Task<ResultsDTO<processk>> Handle(processBackcommond request, CancellationToken cancellationToken)
        {

            try
            {
                var list = new ResultsDTO<processk>() { Code = 0 };
                var str = "select * from processk where processid=" + request.Processid + "";

                var per = new processk();

                DapperHelper dapperHelper = new DapperHelper();

                list.Data = _processk.GetAll(str, per, dapperHelper.MangoMesRead).ToList();
                var OperatorName = "123";
                var OperatorTime = DateTime.Now.ToString();
                var PerformOperation = "工序反填";
                _Logincommonality.Loginaddget(OperatorName, OperatorTime, PerformOperation);

                return list;
            }
            catch (Exception)
            {

                throw;
            }
          
        }

        
    }
}
